package gui;
import java.io.File;

import javax.swing.filechooser.FileFilter;


/***
 * Class for filter files in the fileChooser, only files with the zbj extension
 * @author Federico
 *
 */
public class ZbjFilter extends FileFilter {
	
	final static String ZBJ = "zbj";
	
	public ZbjFilter(){}

	@Override
	public boolean accept(File f) {
		if (f.isDirectory()) { 
            return true; 
        } 
        String s = f.getName(); 
        int i = s.lastIndexOf('.'); 

        if (i > 0 &&  i < s.length() - 1) { 
            String extension = s.substring(i+1).toLowerCase(); 
            if (ZBJ.equals(extension)) { 
                    return true; 
            } else { 
                return false; 
            } 
        } 
        return false; 
	}

	@Override
	public String getDescription() {
		return "Files ."+ZBJ;
	}

}
